/**
 * cn.com.oceansoft.framework.kits.ApiResult
 *
 * @author chenw
 * @create 16/4/27.21:40
 * @email javacspring@hotmail.com
 */

package cn.com.oceansoft.framework.kits;

/**
 * @author chenw
 * @create 16/4/27 21:40
 * @email javacspring@gmail.com
 */
public class ApiResult {

    private boolean succ;
    private int code;
    private String msg;
    private Object data;

    public ApiResult(boolean succ, int code, String msg, Object data) {
        this.succ = succ;
        this.code = code;
        this.msg = msg;
        this.data = data;
    }

    public ApiResult() {
        this(true, 200, "", null);
    }

    public ApiResult(String msg) {
        this(true, 200, msg, null);
    }

    public static ApiResult succ(int code) {
        return new ApiResult(true, 200, "", null);
    }

    public static ApiResult succ(int code, String msg) {
        return new ApiResult(true, code, msg, null);
    }

    public static ApiResult succ(String msg) {
        return new ApiResult(true, 200, msg, null);
    }

    public static ApiResult succ(String msg, Object data) {
        return new ApiResult(true, 200, msg, data);
    }

    public static ApiResult succ(Object data) {
        return new ApiResult(true, 200, "", data);
    }

    public static ApiResult succ(int code, Object data) {
        return new ApiResult(true, code, "", data);
    }

    public static ApiResult failure(int code) {
        return new ApiResult(false, code, "", null);
    }

    public static ApiResult failure(int code, String msg) {
        return new ApiResult(false, code, msg, null);
    }

    public boolean isSucc() {
        return succ;
    }

    public void setSucc(boolean succ) {
        this.succ = succ;
    }

    public int getCode() {
        return code;
    }

    public void setCode(int code) {
        this.code = code;
    }

    public String getMsg() {
        return msg;
    }

    public void setMsg(String msg) {
        this.msg = msg;
    }

    public Object getData() {
        return data;
    }

    public void setData(Object data) {
        this.data = data;
    }


}
